let path  = require("path");
let HtmlWebpackPlugin = require("html-webpack-plugin");

let newDirname = __dirname.replace("config","")
let HtmlPlugin = new HtmlWebpackPlugin({
    filename:"index.html",
    template:"./public/index.html"
})

module.exports = {
    mode:"production",
    entry:'./src/index.js',
    output:{
        filename:"build.js",
        path:path.resolve(newDirname,"build")
    },
    module:{
        rules:[
            {
                test:/\.css$/i,
                use:["style-loader",'css-loader']
            },
            {
                test: /\.(js|jsx)$/,
                exclude: /(node_modules|bower_components)/,
                use: {
                  loader: 'babel-loader',
                  options: {
                    presets: ['@babel/preset-env',"@babel/preset-react"]
                  }
                }
              }
        ]
    },
    plugins:[HtmlPlugin],
}